<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MessageToast 组件演示</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            margin: 0;
            padding: 20px;
            background: #f5f5f5;
        }
        .demo-container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .demo-title {
            text-align: center;
            color: #333;
            margin-bottom: 30px;
        }
        .demo-section {
            margin-bottom: 30px;
        }
        .demo-section h3 {
            color: #555;
            margin-bottom: 15px;
        }
        .demo-buttons {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        .demo-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.2s;
        }
        .demo-btn:hover {
            transform: translateY(-1px);
        }
        .btn-success {
            background: #10b981;
            color: white;
        }
        .btn-warning {
            background: #f59e0b;
            color: white;
        }
        .btn-error {
            background: #ef4444;
            color: white;
        }
        .btn-info {
            background: #3b82f6;
            color: white;
        }
        .btn-custom {
            background: #8b5cf6;
            color: white;
        }
        .code-example {
            background: #f8f9fa;
            border: 1px solid #e9ecef;
            border-radius: 4px;
            padding: 15px;
            margin-top: 15px;
            font-family: 'Courier New', monospace;
            font-size: 13px;
            overflow-x: auto;
        }
    </style>
</head>
<body>
    <div class="demo-container">
        <h1 class="demo-title">MessageToast 消息提示组件演示</h1>
        
        <div class="demo-section">
            <h3>基础用法</h3>
            <div class="demo-buttons">
                <button class="demo-btn btn-success" onclick="showSuccess()">成功消息</button>
                <button class="demo-btn btn-warning" onclick="showWarning()">警告消息</button>
                <button class="demo-btn btn-error" onclick="showError()">错误消息</button>
                <button class="demo-btn btn-info" onclick="showInfo()">信息消息</button>
            </div>
            <div class="code-example">
// 使用全局管理器
import { messageToast } from '@components/common/MessageToast/scripts.js';

messageToast.success('操作成功！');
messageToast.warning('请注意！');
messageToast.error('操作失败！');
messageToast.info('这是一条信息');
            </div>
        </div>

        <div class="demo-section">
            <h3>自定义配置</h3>
            <div class="demo-buttons">
                <button class="demo-btn btn-custom" onclick="showCustom()">自定义标题</button>
                <button class="demo-btn btn-custom" onclick="showLongDuration()">长时间显示</button>
                <button class="demo-btn btn-custom" onclick="showNoProgress()">无进度条</button>
                <button class="demo-btn btn-custom" onclick="showNotClosable()">不可关闭</button>
            </div>
            <div class="code-example">
// 自定义配置
messageToast.show({
    type: 'success',
    title: '自定义标题',
    message: '这是自定义的消息内容',
    duration: 10000,
    showProgress: false,
    closable: false
});
            </div>
        </div>

        <div class="demo-section">
            <h3>组件用法</h3>
            <div class="demo-buttons">
                <button class="demo-btn btn-info" onclick="showComponent()">创建组件实例</button>
                <button class="demo-btn btn-info" onclick="clearAll()">清除所有消息</button>
            </div>
            <div class="code-example">
// 创建组件实例
const toast = document.createElement('message-toast');
document.body.appendChild(toast);
toast.success('使用组件实例显示消息');

// 清除所有消息
messageToast.clear();
            </div>
        </div>
    </div>

    <script type="module">
        import { messageToast } from '/src/components/common/MessageToast/scripts.js';
        
        // 将函数挂载到全局，供按钮调用
        window.showSuccess = () => {
            messageToast.success('操作成功！这是一条成功消息。');
        };
        
        window.showWarning = () => {
            messageToast.warning('请注意！这是一条警告消息。');
        };
        
        window.showError = () => {
            messageToast.error('操作失败！这是一条错误消息。');
        };
        
        window.showInfo = () => {
            messageToast.info('这是一条信息消息，用于提供额外的信息。');
        };
        
        window.showCustom = () => {
            messageToast.show({
                type: 'success',
                title: '自定义标题',
                message: '这是一条带有自定义标题的消息',
                duration: 5000
            });
        };
        
        window.showLongDuration = () => {
            messageToast.info('这条消息会显示10秒钟', {
                duration: 10000
            });
        };
        
        window.showNoProgress = () => {
            messageToast.warning('这条消息没有进度条', {
                showProgress: false
            });
        };
        
        window.showNotClosable = () => {
            messageToast.error('这条消息不能手动关闭', {
                closable: false,
                duration: 3000
            });
        };
        
        window.showComponent = () => {
            const toast = document.createElement('message-toast');
            document.body.appendChild(toast);
            setTimeout(() => {
                toast.success('使用组件实例显示的消息');
            }, 100);
        };
        
        window.clearAll = () => {
            messageToast.clear();
        };
    </script>
</body>
</html>